#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Created on 2018-09-03 16:52:28
# Project: douban
from sqlalchemy.orm import sessionmaker
from db.sqlacmy.SQLAlchemyEntity import engine, Article, Tag

Session = sessionmaker(bind=engine)
session = Session()

#  更新一个字段：
a = session.query(Article).get(10)
a.title = 'My test blog post'
session.add(a)
session.commit()

# 添加一个标签：
a = session.query(Article).get(10)
a.tags.append(Tag(name='python'))
session.add(a)
session.commit()